#ifndef EGG_VIEWPORT_H
#define EGG_VIEWPORT_H

#include "RenderSystem.h"

namespace egg{

    class Viewport{
    public:
        Viewport();
    public:
        inline bool isRenderToWindow(){
            return mTarget->getID()==0;
        }
        inline void setRect(uint32 _l,uint32 _b,uint32 _w,uint32 _h){
            mLeft=_l,mBottom=_b,mWidth=_w,mHeight=_h;
        }
        inline float getAspect() const{
            return float(mWidth)/float(mHeight);
        }
        inline uint32 getRight() const{
            return mLeft+mWidth;
        }
        inline uint32 getTop() const{
            return mBottom+mHeight;
        }
        inline vec4 getRect() const{
            return vec4(mLeft,mBottom,mWidth,mHeight);
        }
        inline vec2 getPixelSize() const{
            return vec2(1.0f/float(mWidth),1.0f/float(mHeight));
        }
        inline void activate(){
            mTarget->activate(mLeft,mBottom,mWidth,mHeight);
        }
        inline void clear(uint32 _mask){
            mTarget->setClearColor(mColor.r,mColor.g,mColor.b,mColor.a);
            mTarget->clear(_mask);
        }
    public:
        bool mSSAO;
        vec4 mColor;
        RenderTargetPtr mTarget;
        uint32 mLeft,mBottom,mWidth,mHeight;
    };

}

#endif